package ljl.alg.wangzheng_camp.round1.dp;

public class _198_rob1 {
    
    /**
     * 哪 wrong了？
     * wrong 就 wrong 在，求完 max 没给 cur，而是 max 自己私吞了，cur 永远是 cur，一个屌丝
     * */
    static class wrong {
        public int rob(int[] nums) {
            int last = 0, cur = nums[0], max = cur;
            for (int i = 1; i < nums.length; i++) {
                int t = nums[i] + last;
                max = Math.max(t, cur);
                last = cur;
                cur = max;
            }
            return max;
        }
    }
    
    static class lufei {
        public int rob(int[] nums) {
            int pre = 0, cur = 0, t;
            for (int num : nums) {
                t = cur;
                cur = Math.max(pre + num, cur);
                pre = t;
            }
            return cur;
        }
    }
}
